﻿using System.Linq;
using System.Web.Mvc;
using StructureMap;

namespace Shp.Web.Bootstrap
{
    public static class BootStrapper
    {
        public static void Bootstrap()
        {
            ObjectFactory.Initialize(x => x.AddRegistry(new DependencyRegistry()));
            DependencyResolver.SetResolver(
                t =>
                    {
                        try
                        {
                            return ObjectFactory.GetInstance(t);
                        }
                        catch
                        {
                            return null;
                        }
                    },
                t => ObjectFactory.GetAllInstances<object>().Where(s => s.GetType() == t)
                );
        }
    }
}